package cn.tedu.carehome.foundation.controller;


import cn.tedu.carehome.foundation.pojo.vo.RoleCountVO;
import cn.tedu.carehome.foundation.pojo.vo.VisitorWeekCountVO;
import cn.tedu.carehome.foundation.service.IStaticService;
import cn.tedu.carehome.foundation.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 这个控制器不需要权限,它用于首页展示
 *
 * @author 袁田
 */

@Slf4j
@Api("简单统计管理")
@Validated
@RestController
@RequestMapping("/static")

public class StaticController {


    @Autowired
    IStaticService staticService;

    @ApiOperation("查询指定角色名的员工数量")
    @PostMapping("/{name}/staff-num")
    @ApiImplicitParam(name = "name", value = "角色名", required = true, example = "院长", dataType = "String")
    @ApiOperationSupport(order = 100)
    public JsonResult<Integer> StaffCountByRole(@PathVariable String name) {
        log.debug("查询名：{}", name);
        Integer num = staticService.StaffCountByRole(name);
        return JsonResult.ok(num);
    }

    @GetMapping("/staff-num")
    @ApiOperation("查询员工总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> StaffCount() {
        log.debug("开始处理统计员工总数请求");
        Integer num = staticService.StaffCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/bed-num")
    @ApiOperation("查询床位总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> BedCount() {
        log.debug("开始处理统计床位总数请求");
        Integer num = staticService.BedCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/floor-num")
    @ApiOperation("查询楼层总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> FloorCount() {
        log.debug("开始处理统计楼层总数请求");
        Integer num = staticService.FloorCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/food-num")
    @ApiOperation("查询餐品总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> FoodCount() {
        log.debug("开始处理统计餐品总数请求");
        Integer num = staticService.FoodCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/medicine-num")
    @ApiOperation("查询药品总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> MedicineCount() {
        log.debug("开始处理统计药品总数请求");
        Integer num = staticService.MedicineCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/older-num")
    @ApiOperation("查询老人总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> OlderCount() {
        log.debug("开始处理统计老人总数请求");
        Integer num = staticService.OlderCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/ill-num")
    @ApiOperation("查询疾病总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> IllCount() {
        log.debug("开始处理统计老人总数请求");
        Integer num = staticService.IllCount();
        return JsonResult.ok(num);
    }

    //高康后台首頁統計
    @GetMapping("/visitor-num")
    @ApiOperation("查询訪客总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> visitorCount() {
        Integer num = staticService.visitorCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/nocheck-num")
    @ApiOperation("查询訪客总数")
    @ApiOperationSupport(order = 200)
    public JsonResult<Integer> nocheckCount() {

        Integer num = staticService.NocheckCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/check-num")
    @ApiOperation("查询入住总数")
    public JsonResult<Integer> checkCount() {

        Integer num = staticService.checkCount();
        return JsonResult.ok(num);
    }

    @GetMapping("/floor-list")
    @ApiOperation("查询楼层总数")
    public JsonResult<Integer[]> floorList() {
        return JsonResult.ok(staticService.floorList());
    }

    @GetMapping("/floorcount-list")
    @ApiOperation("查询楼层")
    public JsonResult<Integer[]> floorcountList() {
        return JsonResult.ok(staticService.floorCountList());
    }

    @GetMapping("/floorBedcount-list")
    @ApiOperation("查询楼层床位总数")
    public JsonResult<Integer[]> floorBedcountList() {
        return JsonResult.ok(staticService.floorBedCount());
    }

    @GetMapping("/floorBedcountplus")
    @ApiOperation("查询楼层床位总数")
    public List<VisitorWeekCountVO> floorBedcountListplus() {
        return staticService.floorBedCountplus();
    }


    @GetMapping("/visitorWeekCount-list")
    @ApiOperation("查询訪客总数")
    public JsonResult<List<VisitorWeekCountVO>> visitorWeekCountList() {
        log.debug("{}", staticService.visitorWeekCount());
        return JsonResult.ok(staticService.visitorWeekCount());
    }

    @GetMapping("/role-list")
    @ApiOperation("查询訪客总数")
    public JsonResult<List<RoleCountVO>> roleCountList() {
        return JsonResult.ok(staticService.roleCount());
    }
}
